import fetch from 'node-fetch';

const testApi = async () => {
    console.log('开始测试管理后台API接口...\n');
    
    const baseUrl = 'http://localhost:8000/api/v1';
    const authToken = 'Bearer admin_token';
    
    try {
        // 先测试一个简单的前台接口验证连接
        console.log('🔥 测试前台接口: 获取分类列表');
        const testResponse = await fetch(`${baseUrl}/index/category`, {
            method: 'GET'
        });
        const testResult = await testResponse.text();
        console.log(`状态码: ${testResponse.status}`);
        console.log(`响应: ${testResult.substring(0, 200)}...\n`);
        
        // 测试接口15: 获取统计数据
        console.log('🔥 测试接口15: 获取统计数据');
        const response1 = await fetch(`${baseUrl}/admin/data/info`, {
            method: 'GET',
            headers: {
                'Authorization': authToken
            }
        });
        const result1 = await response1.text();
        console.log(`状态码: ${response1.status}`);
        console.log(`响应: ${result1}\n`);
        
        // 测试接口16: 日新增文章数量统计
        console.log('🔥 测试接口16: 日新增文章数量统计');
        const response2 = await fetch(`${baseUrl}/admin/data/article`, {
            method: 'GET',
            headers: {
                'Authorization': authToken
            }
        });
        const result2 = await response2.text();
        console.log(`状态码: ${response2.status}`);
        console.log(`响应: ${result2}\n`);
        
    } catch (error) {
        console.error('测试失败:', error.message);
    }
};

testApi();
